import systemStoreHook from "@/stores/modules/system";
import {commonState} from "@/common/index.js";

const systemStore = systemStoreHook();

export const pageSearch = reactive({
    pageNumber: commonState.pageNumber,
    pageSize: commonState.pageSize,
});
export const tableState = reactive({
    totalCount: 0,
    records: []
});

export const state = reactive({
    selectedRowKeys: [],
    loading: false,
    subLoading: false,
});
export const setLoading = (loading) => {
    state.loading = loading;
}

export const setSubLoading = (loading) => {
    state.subLoading = loading;
}

//表单列表
export const columns = [
    {
        title: '字典编码',
        dataIndex: 'dictCode',
        key: 'dictCode',
        align: 'left',
        ellipsis: true
    },
    {
        title: '字典项Key',
        dataIndex: 'key',
        key: 'key',
        align: 'left',
        ellipsis: true
    },
    {
        title: '字典项值',
        dataIndex: 'value',
        key: 'value',
        align: 'left',
        ellipsis: true
    },
    {
        title: '字典项名',
        dataIndex: 'name',
        key: 'name',
        align: 'left',
        ellipsis: true
    },
    {
        title: '操作',
        key: 'operation',
        fixed: 'right',
        align: 'center'
    }
]
export const rules = reactive({
    dictCode: [{required: true, message: '请输入字典编码', trigger: 'blur'}],
    value: [{required: true, message: '请输入字典项值', trigger: 'blur'}],
    key: [{required: true, message: '请输入字典项key', trigger: 'blur'}],
    name: [{required: true, message: '请输入字典项名称', trigger: 'blur'}],
});
//明细
export const detailState = reactive({})

//设置查询参数
export function setSearchParam() {
    Object.assign(pageSearch, systemStore.getDictItemSearch);
    return pageSearch;
}
